#ifndef STACK_H
#define STACK_H

/* *
 * 同queue 类似，都是借用了 deque 的头尾都可进出的能力，实现了先进后出的栈
*/

#include "deque.h"

//GCC2.95

template <class _Tp, class _Sequence = deque<_Tp> >
class stack {
public:
  typedef typename _Sequence::value_type      value_type;
  typedef typename _Sequence::size_type       size_type;
  typedef          _Sequence                  container_type;

  typedef typename _Sequence::reference       reference;
  typedef typename _Sequence::const_reference const_reference;
protected:
  _Sequence _M_c;
public:
  stack() : _M_c() {}
  explicit stack(const _Sequence& __s) : _M_c(__s) {}

  bool empty() const { return _M_c.empty(); }
  size_type size() const { return _M_c.size(); }
  reference top() { return _M_c.back(); }
  const_reference top() const { return _M_c.back(); }
  void push(const value_type& __x) { _M_c.push_back(__x); }//在尾部添加一个元素
  void pop() { _M_c.pop_back(); }//在尾部删除一个元素
};

#endif // STACK_H
